package com.turman.composebook.views

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import com.turman.composebook.R

@Composable
fun LottieSampleView(modifier: Modifier = Modifier) {
    var times by remember {
        mutableStateOf(1)
    }
    val composition by rememberLottieComposition(spec = LottieCompositionSpec.RawRes(R.raw.tg))
    val progress by animateLottieCompositionAsState(composition = composition, iterations = times)
    Column(modifier = modifier.fillMaxSize()) {
        LottieAnimation(
            composition = composition,
            progress = progress,
            modifier = Modifier.clickable {
                times++
            })
    }
}



































